<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>任务报表</title>
    <div th:include="layout/resources :: resources"></div>
</head>
<body>
<div class="container-fluid">
    <table id="taskReport"></table>
</div>
</body>
<script type="text/javascript">
    $("#taskReport").framework().bootstrapTable({
        url: "/taskReport/getListByPage",
        columns: [
            {
                field: '',
                title: '序号',
                align: 'center',
                valign: 'middle',
                formatter: function (value, row, index) {
                    return index + 1;
                }
            }, {
                field: 'funName',
                title: '項目',
                align: 'center',
                valign: 'middle'
            }, {
                field: 'flowName',
                title: '流程名',
                align: 'center',
                valign: 'middle'
            }, {
                field: 'successCount',
                title: '成功数量',
                align: 'center',
                valign: 'middle'
            }, {
                field: 'realSuccessCount',
                title: '实际成功次数',
                align: 'center',
                valign: 'middle',
                formatter: function (value, row, index) {
                    return '<a href="javascript:updateRealSuccessCount(\'' + row.id + '\');">' + value + '</a>';
                }
            }, {
                field: 'reportDate',
                title: '统计日期',
                align: 'center',
                valign: 'middle'
            }]
    });

    function updateRealSuccessCount(id) {
        layer.prompt({title: '输入内容，并确认', formType: 2}, function (param, index) {
            $.ajax({
                method: "get",
                url: createUrl('/taskReport/updateRealSuccessCount?id=' + id + "&realSuccessCount=" + param),
                success: function (result) {
                    if (result.success) {
                        refresh();
                        framework.alert("修改成功");
                    } else {
                        framework.alert("修改失敗:" + result.error);
                    }
                    layer.close(index);
                }
            })
        });
    }

    function refresh() {
        $('#taskReport').bootstrapTable('refresh');
    }
</script>
</html>
